﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace FuelTracker.Models
{
    public class FuelLog
    {
        public DateTime Date { get; set; }
        public decimal DistanceDriven { get; set; }
        public decimal FuelAmount { get; set; }
        public decimal TotalPrice { get; set; }
        public DistanceUnit DistanceUnit { get; set; }
        public FuelUnit FuelUnit { get; set; }

        public decimal AvgConsumption
        {
            get
            {
                if (DistanceDriven <= 0)
                {
                    return 0;
                }

                return FuelAmount / DistanceDriven * 100;
            }
        }

        public decimal FuelPricePerUnit
        {
            get
            {
                if (FuelAmount <= 0)
                {
                    return 0;
                }

                return TotalPrice / FuelAmount;
            }
        }

        /*
         * Parameterloser Konstruktor fuer die Serialisierung
         */
        public FuelLog()
        { }


        public FuelLog(DateTime date, decimal distanceDriven, decimal fuelAmount, decimal totalPrice)
        {
            Date = date;
            DistanceDriven = distanceDriven;
            FuelAmount = fuelAmount;
            TotalPrice = totalPrice;
        }
    }
}
